<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<h1>Tweaks</h1>
On this page you can find ways to improve performance and lower resource consumptions
of a running <b>client</b>.<br>
<br>

<h2>Disable counters</h2>
Edit the <a href="gocoin_manual_config.html">config file</a> and set the value of <code>Stats.NoCounters</code> to <b>true</b>.<br>
This will turn off node's internal statistics which should improve performance.<br>
<br>

<h2>Turn off caching on disk</h2>
Edit the <a href="gocoin_manual_config.html">config file</a> and set the value of <code>Memory.CacheOnDisk</code> to <b>false</b>.<br>
This will prevent the node from caching blocks on disk, 
which may improve initial chain sync performance (at a cost of using more RAM).<br>
<br>

<h2>Disable wallet functionality</h2>

You can disable node's wallet functionality, to save system memory used by a running client
and improve block processing times.<br>
In order to do so, use TextUI command <code>wallet off</code> or click the disable wallet button on the bottom of the <b>Wallet</b> page in the WebUI.<br>
<br>
If you don't want the wallet functionality to automatically enable after the node is started,
set the value of <code>AllBalances.AutoLoad</code> to <code>false</code> in the
<a href="gocoin_manual_config.html">config file</a>.<br>
<br>
<i>Note: You can manually enable wallet functionality at any time while the node is running,
either from WebUI or by executing TextUI command <code>wallet on</code></i><br>
<br>
<a name="libsecp256k1"></a>
<h2>External secp256k1 speedups</h2>

It is possible to use <a target="_blank" href="https://github.com/bitcoin/bitcoin/tree/master/src/secp256k1">libsecp256k1</a>
(maintained by <a target="_blank" href="https://github.com/bitcoin/bitcoin/">Bitcoin Core</a> project)
that is written in C and assembler.<br>
<br>

<i><b>Note:</b>
Thanks to the recent improvements, an external library does not always perform better than the Gocoin's native one.<br>
To check if it does, use test programs from <code>gocoin/lib/others/cgo/ec_bench/</code> - for instance: <code>go run gonative.go</code> vs <code>go run sipasec.go</code></i><br>
<br>

To make Gocoin client to use the external library, copy either the file
<code>sipadll.go</code> (Windows only) or <code>sipasec.go</code> (any OS),
from <code>gocoin/client/speedups/</code> to its parent folder (<code>gocoin/client/</code>).
Then rebuild and restart the client.<br>
<i>Note: You can have either <code>sipadll.go</code> or <code>sipasec.go</code> in your
<code>gocoin/client/</code> folder, but never both of them as the client will not build then.</i><br>
<br>
Depending which speedup file you chose, follow either of the instructions in the table below.<br>
<br>
<table border="1" cellpadding="5" cellspacing="0">
<tr>
    <td align="center" width="65%"><b>sipasec.go</b></td>
    <td align="center" width="35%"><b>sipadll.go</b> (Windows only)</td>
</tr>
<tr>

<td valign="top">
In order to use <code>sipasec.go</code> speedup, build and install <b>secp256k1</b> library in your system.<br>
<br>
On Debian based Linux system, simply execute the following commands:<br>

<code>&nbsp;&nbsp;sudo apt-get install gcc automake autoconf libtool make git libgmp-dev</code> <br>
<code>&nbsp;&nbsp;git clone https://github.com/bitcoin/bitcoin.git</code> <br>
<code>&nbsp;&nbsp;cd bitcoin/src/secp256k1/</code> <br>
<code>&nbsp;&nbsp;./autogen.sh</code> <br>
<code>&nbsp;&nbsp;./configure</code> <br>
<code>&nbsp;&nbsp;make</code> <br>
<code>&nbsp;&nbsp;sudo make install</code> <br>
<br>
<i>Note: When the library is properly installed, executing <code>go test</code> inside
<code>gocoin/lib/others/cgo/sipasec/</code> says <b>PASS</b></i>
</td>

<td valign="top">
To use <code>sipadll.go</code> speedup, you have to place <b>secp256k1.dll</b>
in <code>gocoin/client/</code> or in any folder where Windows looks for executables
(e.g. <code>C:\WINDOWS</code>).<br>
<br>
You can find <b>secp256k1.dll</b> in <code>gocoin/tools/sipa_dll/</code>
or you can download it from <a target="_blank" href="https://sourceforge.net/projects/gocoin/files/?source=directory">sourceforge.net</a>
(it's inside <a target="_blank" href="https://sourceforge.net/projects/gocoin/files/secp256k1.dll_v2-amd64.zip/download">secp256k1.dll_v2-amd64.zip</a>).<br>
<br>
To build <b>secp256k1.dll</b> youself, look into
<a target="_blank" href="https://sourceforge.net/projects/gocoin/files/secp256k1_win_v2.zip/download">secp256k1_win_v2.zip</a>.
</td>

</tr>
</table>
<br>

<h2>Compress UTXO records</h2>
To save some system memory as well as a disk space, although at the cost of a performance, you can compress UTXO database.<br>
<br>
In order to do this, execute the tool <code>utxo_compress</code>.<br>
The tool needs to be executed from inside the data folder - where the <code>UTXO.db</code> file is.<br>
The node must not be running while executing the tool.<br>
<br>
You can reverse the operation of compressing the database, be running <code>utxo_decompress</code>.<br>
<br>

<h2>Garbage Collector and UTXO heap</h2>
If you have RAM to spare, try switching UTXO records to Go's heap manager 
and increasing Garbage Collector's treshold.<br>
This will increase memory usage, but should improve block processing performance
(e.g. during initial blockchain download).<br>
<br>
Edit the <a href="gocoin_manual_config.html">config file</a> to set
<code>Memory.UseGoHeap</code> to <b>true</b> and
<code>Memory.GCPercTrshold</code> to <b>100</b> or more (higher value for more effect).<br>
You may also try only increasing <code>Memory.GCPercTrshold</code>, leaving <code>Memory.UseGoHeap</code> set to <b>false</b>.<br>
<br>
<i>Note: The node needs to be restarted to apply a new value of <code>Memory.UseGoHeap</code></i>
</body>
</html>
